package org.example.backend.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.example.backend.common.Result;
import org.example.backend.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author 啊昌
 * @date 2025/7/19 23:21
 * CategoryController 分类controller
 */
@Tag(name = "分类管理")
@RestController
public class CategoryController {
	@Autowired
	private CategoryService categoryService;

	@GetMapping("/getCategory")
	@Operation(summary = "获取分类的接口") //categories/{parent_id} -》@PathVariable("parent_id")
	public Result<Map<String, Object>> getCategory() {
		// parent_id = 0 表示一级
		Result<Map<String, Object>> category = categoryService.getCategory(null);
		return category;
	}
}
